<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Token在线生成</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/twitter-bootstrap/4.2.1/js/bootstrap.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <!--  Validator  -->
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-validator/0.5.3/css/bootstrapValidator.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

    <script th:inline="javascript">
        $(document).ready(function() {
            $("button").click(function () {
                var userId = document.getElementById("UserId").value;
                var expireTime = document.getElementById("expireTime").value;
                $.ajax({
                    url:"/users/getToken",
                    type:"post",
                    data:"userId=" + userId + "&expireTime=" + expireTime,
                    success:function (data) {
                        if(data.result){
                            var tokenVal = document.getElementById("tokenVal");
                            tokenVal.value = data.data;
                        }else{
                            alert(data.msg);
                        }
                    }
                })
            });
        });
    </script>
</head>
<body>
    <h1 style="text-align: center;margin: 100px auto">Token在线生成</h1>
    <div class="form-inline text-center">
        <div class="form-group">
            <label for="UserId">UserId</label>
            <input type="text" class="form-control" id="UserId" placeholder="YDZ" data-bv-notempty="true"
                   data-bv-notempty-message="不能为空">
        </div>
        <div class="form-group">
            <label for="expireTime">ExpireTime</label>
            <input type="text" class="form-control" id="expireTime" name="expireTime" value="112233">
        </div>
        <button type="submit" class="btn btn-primary">生成Token</button>
    </div>
    <br/>
    <div role="form">
        <div class="form-group">
            <textarea id="tokenVal" class="form-control" rows="3" style="width: 32%;height: 200px;margin: 0 auto"></textarea>
        </div>
    </div>
</body>
</html>